<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <script type="text/javascript" src="${ctx}/appjs/hlht/auditHlhtTenantOpenApply.js"></script>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">主页</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>互联互通</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>互联互通申请详情</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });
</script>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">互联互通申请详情</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frmAuditHlhtTenantOpenApply">
                        <input type="hidden" id="openApplyId" name="openApplyId" value="${hlhtTenantOpenApply.openApplyId}" >
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">发设备运营商：</label>
                            <div class="col-sm-8">
                                <input type="hidden" class="form-control" id="tenantCode" name="tenantCode"
                                       value="${hlhtTenantOpenApply.tenantCode}"   readonly>
                                <input type="text" class="form-control" value="${tenant.tenantName}" readonly>
                                <%--分销商--%>
                                <input type="hidden" name="tenantOperatorCode" value="${hlhtTenantOpenApply.tenantOperatorCode}">
                            </div>
                        </div>
                        <c:if test="${hlhtTenantOpenApply.hlhtOpenType == '0'}">
                            <div class="form-group row">
                                <label class="col-sm-3 col-form-label text-right">对方运营商：</label>
                                <div class="col-sm-8">
                                    <input id="hlhtTenantCode" name="hlhtTenantCode" class="form-control" type="hidden"
                                           value="${hlhtTenantOpenApply.hlhtTenantCode}" readonly>
                                    <input class="form-control" type="text" value="${hlhtTenant.tenantName}" readonly>
                                </div>
                            </div>
                        </c:if>
                        <c:if test="${hlhtTenantOpenApply.hlhtOpenType != '0'}">
                            <div class="form-group row">
                                <label class="col-sm-3 col-form-label text-right">对方运营商：</label>
                                <div class="col-sm-8">
                                    <input id="hlhtOperatorId" name="hlhtOperatorId" class="form-control" type="hidden"
                                           value="${hlhtTenantOpenApply.hlhtOperatorId}">
                                    <input class="form-control" type="text" value="${operator.hlhtOperatorName}" readonly>
                                </div>
                            </div>
                        </c:if>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">结算方式：</label>
                            <div class="col-sm-8">
                                <select disabled class="form-control" id="settleType" name="settleType">
                                    <option value="0" ${hlhtTenantOpenApply.settleType=="0"?"selected":""}>由平台参与对账结算</option>
                                    <option value="1" selected>直接对账结算</option>
                                    <option value="2" ${hlhtTenantOpenApply.settleType=="2"?"selected":""}>不需结算(政府类)</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联开始时间：</label>
                            <div class="col-sm-8">
                                <input id="beginDate"
                                       name="beginDate"
                                       type="text"
                                       value="<fmt:formatDate value="${hlhtTenantOpenApply.beginDate}"
                                       pattern="yyyy-MM-dd" />" disabled class="form-control"
                                       placeholder="结束时间">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联结束时间：</label>
                            <div class="col-sm-8">
                                <input id="endDate"
                                       name="endDate"
                                       type="text"
                                       value="<fmt:formatDate value="${hlhtTenantOpenApply.endDate}"
                                       pattern="yyyy-MM-dd" />" disabled class="form-control"
                                       placeholder="结束时间">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right" onclick="window.open('v0.ftp.upyun.com2/enterprise/2020052611171533.pdf')">开放类型：</label>
                            <div class="col-sm-8">
                                <select disabled class="form-control" id="hlhtOpenType" name="hlhtOpenType">
                                    <option value="0" selected>内部互联</option>
                                    <option value="1" ${hlhtTenantOpenApply.hlhtOpenType=="1"?"selected":""}>外部互联</option>
                                    <option value="2" ${hlhtTenantOpenApply.hlhtOpenType=="2"?"selected":""}>政务互联</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">开放方向：</label>
                            <div class="col-sm-8">
                                <select disabled class="form-control" id="hlhtType" name="hlhtType">
                                    <option value="0" selected>反向</option>
                                    <option value="1" ${hlhtTenantOpenApply.hlhtType=="1"?"selected":""}>正向</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">附件：</label>
                            <div class="col-sm-8">
                                <div id="">
                                    <c:choose>
                                        <c:when test="${hlhtTenantOpenApply.contractFile!=null && hlhtTenantOpenApply.contractFile!=''}">
                                            <a id="contractFile" href="${uploadPath}${hlhtTenantOpenApply.contractFile}">${hlhtTenantOpenApply.contractFile}</a>
                                            <input  type="hidden" id="fileName" name="fileName" value="">
                                            <input type="file" hidden name="docfile"/>
                                        </c:when>
                                        <c:otherwise>
                                            <a id="contractFile" href="#"></a>
                                            <input  type="hidden" id="fileName" name="fileName" value="">
                                            <input type="file" id="docfile" name="docfile"/>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">申请理由：</label>
                            <div class="col-sm-8">
                                <input id="remark" name="remark" class="form-control" type="text"
                                       value="${hlhtTenantOpenApply.remark}" readonly>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">互联状态：</label>
                            <div class="col-sm-8">
                                <select disabled class="form-control" id="status" name="status">
                                    <option value="0" selected>未审核</option>
                                    <option value="1" ${hlhtTenantOpenApply.status=="1"?"selected":""}>审核通过</option>
                                    <option value="2" ${hlhtTenantOpenApply.status=="2"?"selected":""}>审核不通过</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <a class="btn btn-primary btn-sm" href="javascript:window.history.back()">返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        var beginDate = laydate.render({
            elem: '#beginDate',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click'
        });
        var endDate = laydate.render({
            elem: '#endDate',
            type: 'date',
            format: 'yyyy-MM-dd',
            trigger: 'click'
        });
    });

    function formatFileName(){
        var fileName =  $("#contractFile").text();
        var crossbarIndex = fileName.indexOf("-");
        var dotIndex = fileName.lastIndexOf(".");
        var deleteStr = fileName.substring(crossbarIndex, dotIndex);
        if (crossbarIndex == -1){
            deleteStr = "";
        }
        fileName = fileName.replace(deleteStr, "");
        var fileLength = fileName.length;
        fileName = fileName.substring(fileName.lastIndexOf("/")+1, fileLength);
        $("#contractFile").text(fileName)
    }
    window.onload = function(){
        formatFileName();
    }

    $("#file1").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractImg1").attr("src", objUrl);
        }
    });

    $("#file2").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractImg2").attr("src", objUrl);
        }
    });

    $("#docfile").change(function () {
        if (this.files[0].size > 5*1024*1024){
            parent.layer.msg("文件大小大于5M");
            return false;
        }
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        if (objUrl) {
            $("#contractFile").attr("href", objUrl);
            $("#contractFile").text(objUrl.name);
        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }
    auditHlhtTenantOpenApply.init();
</script>
</body>
</html>
